from flask_restful import Resource, reqparse, marshal_with
from sqlalchemy import and_

from apps.common.result import Result
from apps.main.models import Movies
from apps.search_movie.fields import result


class SearchMovieListApi(Resource):
    def __init__(self):
        self.parser = reqparse.RequestParser()
        self.parser.add_argument('movie_id', type=int)

    @marshal_with(result)
    def get(self):
        args = self.parser.parse_args()
        movie_id = args.get('movie_id')
        movie = Movies.query.filter(and_(Movies.is_delete == 0,Movies.mid ==movie_id)).first()
        data = {
            'movie':movie
        }
        return Result.get_success_result_obj(data)